float contrastCoefficient = 2.0;
float saturationCoefficient = 2.0;
float4 tintCoefficient = float4(1.0, 0.5, 0.5, 1.0);
float BlurDistance = 0.002;

sampler samplerState;

struct PShaderInput
{
	float2 TexCoord : TEXCOORD0;
};

float4 clone(struct PShaderInput input) : COLOR0
{
	return tex2D( samplerState, input.TexCoord );
}

float4 invert(struct PShaderInput input) : COLOR0
{
	float4 output = 1.0 - tex2D( samplerState, input.TexCoord );
	output.a = 1;
	return output;
}

float4 contrast(struct PShaderInput input) : COLOR0
{
	float4 colorSample = tex2D( samplerState, input.TexCoord );

	colorSample = pow(colorSample, contrastCoefficient);
	colorSample.a = 1;
	return colorSample;
}

float4 saturation(struct PShaderInput input) : COLOR0
{
	float4 colorSample = tex2D( samplerState, input.TexCoord );

	float grey = dot(colorSample, float3(0.3, 0.59, 0.11));
	colorSample.rgb = lerp(grey, colorSample, saturationCoefficient).rgb;
	colorSample.a = 1;
	return colorSample;
}

float4 tint(struct PShaderInput input) : COLOR0
{
	float4 colorSample = tex2D( samplerState, input.TexCoord );

	colorSample *= tintCoefficient;
	colorSample.a = 1;
	return colorSample;
}

float4 blur(struct PShaderInput input) : COLOR0
{
	float4 colorSample = tex2D( samplerState, input.TexCoord );

	colorSample += tex2D( samplerState, float2(input.TexCoord.x+BlurDistance, input.TexCoord.y+BlurDistance));
    colorSample += tex2D( samplerState, float2(input.TexCoord.x-BlurDistance, input.TexCoord.y-BlurDistance));
    colorSample += tex2D( samplerState, float2(input.TexCoord.x+BlurDistance, input.TexCoord.y-BlurDistance));
	colorSample += tex2D( samplerState, float2(input.TexCoord.x-BlurDistance, input.TexCoord.y+BlurDistance));
	colorSample = colorSample / 5;

	colorSample.a = 1;

	return colorSample;
}

technique Clone
{
	pass P0
	{
		PixelShader = compile ps_2_0 clone();
	}
}

technique Invert
{
	pass P0
	{
		PixelShader = compile ps_2_0 invert();
	}
}

technique Contrast
{
	pass P0
	{
		PixelShader = compile ps_2_0 contrast();
	}
}

technique Saturation
{
	pass P0
	{
		PixelShader = compile ps_2_0 saturation();
	}
}

technique Tint
{
	pass P0
	{
		PixelShader = compile ps_2_0 tint();
	}
}

technique Blur
{
	pass P0
	{
		PixelShader = compile ps_2_0 blur();
	}
}
